package cards.templates;

import java.util.Calendar;

import cards.Card;
import cards.CardType;
import cards.params.UpToDateParams;

public class CardUpToDate extends Card {

	private Calendar expDate;
	
	{
		// Set expiration Date to Yesterday
		expDate = Calendar.getInstance();
		expDate.roll(Calendar.DAY_OF_YEAR, false);
	}
	
	@Override
	public boolean check() {
		Calendar now = Calendar.getInstance();
		return expDate.after(now);
	}
	
	public Calendar getExpDate() {
		return expDate;
	}

	@Override
	public Card newInstance(CardType type) {
		CardUpToDate newcard = new CardUpToDate();
		UpToDateParams params = (UpToDateParams)type.getParams();
		int days = params.getDays();
		Calendar expDate = Calendar.getInstance();
		expDate.roll(Calendar.DAY_OF_YEAR, days);
		newcard.expDate = expDate;
		return newcard;
	}

}
